<template>
  <div class="page">
    <input :type="text" @blur="onBlur" :value="value" @input="Input">
  </div>
</template>

<script type="text/ecmascript-6">
//1.失去焦点触发校验
//2.输入时触发校验
export default {
  props: {
    value: {
      type: String,
      default: "" //初始值，如果有值就会被覆盖
    },
    text: {
      type: String,
      default: ""
    }
  },
  data() {
    return {};
  },
  methods: {
    onBlur() {
      this.$dispatch("validate");
    },
    Input(event) {
      this.$emit("input", event.target.value);
      this.$dispatch("validate");
    }
  },
  components: {},
  created() {}
};
</script>

<style scoped>
</style>
